theme-juice 0.3.8 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/bin/tj +2 -0
- data/lib/theme-juice.rb +4 -4
- data/lib/theme-juice/cli.rb +135 -51
- data/lib/theme-juice/executor.rb +148 -84
- data/lib/theme-juice/ui.rb +217 -0
- data/lib/theme-juice/utilities.rb +14 -30
- data/lib/theme-juice/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9ba65703ebc0aa6c3347653be95257dc44c0139b
         | 
| 4 | 
            +
              data.tar.gz: acb64611b4953ea3f6dd9bdcd031ab041db4f934
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6b2861fd3f7b839f44a68105518afc10407e783457f1aec6e72ed0fbee5ca3a7f771080d82bde4745958dcc619cf6f22155ad7a8b71c5996e3a9daf06322912a
         | 
| 7 | 
            +
              data.tar.gz: 284659d59c835d0a31f84813bcc22e8e0ea49d08055d126138735a5999e183fdf4423e01b84d10ac33e07003c27ff4f74bcca34fedd2f79f27c7192e6b05c3b6
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # Theme Juice [](https://rubygems.org/gems/theme-juice)
         | 
| 2 2 | 
             
            What is it? Theme Juice is a command line interface created to scaffold out a new WordPress development environment (using [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV)) and countless development sites. Everybody loves one command setups, and `tj` can even do one command deployments too.
         | 
| 3 3 |  | 
| 4 4 | 
             
            ## Installation
         | 
| @@ -39,9 +39,11 @@ tj | |
| 39 39 | 
             
            ```
         | 
| 40 40 |  | 
| 41 41 | 
             
            ### Global flags:
         | 
| 42 | 
            -
            | Flag | 
| 43 | 
            -
             | 
| 44 | 
            -
            | `- | 
| 42 | 
            +
            | Flag                     | Type   | Description                                |
         | 
| 43 | 
            +
            |:-------------------------|:------ |:------------------------------------------ |
         | 
| 44 | 
            +
            | `-nu, [--no-unicode]`    | Bool   | Disable all unicode characters             |
         | 
| 45 | 
            +
            | `-nc, [--no-colors]`     | Bool   | Disable colored output                     |
         | 
| 46 | 
            +
            | `-fp, [--vvv-path=PATH]` | String | Force custom path to your VVV installation |
         | 
| 45 47 |  | 
| 46 48 | 
             
            ### Print version:
         | 
| 47 49 | 
             
            This command will print the current version of `tj`.
         | 
| @@ -89,7 +91,7 @@ tj list # Aliases: sites, show | |
| 89 91 | 
             
            ### Watching and compiling assets:
         | 
| 90 92 | 
             
            Use this to watch and compile assets with your preferred build tool, whether that be [Grunt](https://github.com/gruntjs/grunt), [Gulp](https://github.com/gulpjs/gulp), [Guard](https://github.com/guard/guard), or whatever. This is simply a wrapper for whatever command is in your `tj-config.yml` file.
         | 
| 91 93 | 
             
            ```bash
         | 
| 92 | 
            -
            tj watch # Aliases: dev
         | 
| 94 | 
            +
            tj watch # Aliases: dev, assets
         | 
| 93 95 | 
             
            ```
         | 
| 94 96 |  | 
| 95 97 | 
             
            ### Managing development environment:
         | 
| @@ -101,13 +103,13 @@ tj vm # Aliases: vagrant, vvv | |
| 101 103 | 
             
            ### Managing vendor dependencies:
         | 
| 102 104 | 
             
            Use this to easily manage your dependencies with [Composer](https://github.com/composer/composer), or whatever other command you set in your `tj-config.yml`. This is a wrapper for whatever command is in your config file.
         | 
| 103 105 | 
             
            ```bash
         | 
| 104 | 
            -
            tj vendor # Aliases: deps
         | 
| 106 | 
            +
            tj vendor # Aliases: dep, deps
         | 
| 105 107 | 
             
            ```
         | 
| 106 108 |  | 
| 107 109 | 
             
            ### Managing deployment and migration:
         | 
| 108 110 | 
             
            Use this to easily manage your deployment and migration with [Capistrano](https://github.com/capistrano/capistrano) (or again, anything else set within your `tj-config.yml`). This is just a wrapper for your chosen command.
         | 
| 109 111 | 
             
            ```bash
         | 
| 110 | 
            -
            tj server # Aliases: deploy
         | 
| 112 | 
            +
            tj server # Aliases: deploy, remote
         | 
| 111 113 | 
             
            ```
         | 
| 112 114 |  | 
| 113 115 | 
             
            ### Executing WP-CLI locally inside your VM with `wp-cli-ssh`
         | 
    
        data/bin/tj
    CHANGED
    
    
    
        data/lib/theme-juice.rb
    CHANGED
    
    | @@ -6,11 +6,11 @@ require "rubygems" | |
| 6 6 | 
             
            require "thor"
         | 
| 7 7 | 
             
            require "yaml"
         | 
| 8 8 |  | 
| 9 | 
            +
            module ThemeJuice
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 9 12 | 
             
            require_relative "theme-juice/version"
         | 
| 13 | 
            +
            require_relative "theme-juice/ui"
         | 
| 10 14 | 
             
            require_relative "theme-juice/utilities"
         | 
| 11 15 | 
             
            require_relative "theme-juice/executor"
         | 
| 12 16 | 
             
            require_relative "theme-juice/cli"
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            module ThemeJuice
         | 
| 15 | 
            -
                # Silence is golden?
         | 
| 16 | 
            -
            end
         | 
    
        data/lib/theme-juice/cli.rb
    CHANGED
    
    | @@ -6,28 +6,68 @@ module ThemeJuice | |
| 6 6 | 
             
                    map %w[setup, init, prep]        => :create
         | 
| 7 7 | 
             
                    map %w[remove, trash, teardown]  => :delete
         | 
| 8 8 | 
             
                    map %w[sites, show]              => :list
         | 
| 9 | 
            -
                    map %w[dev] | 
| 9 | 
            +
                    map %w[assets, dev]              => :watch
         | 
| 10 10 | 
             
                    map %w[dep, deps]                => :vendor
         | 
| 11 | 
            -
                    map %w[deploy] | 
| 11 | 
            +
                    map %w[deploy, remote]           => :server
         | 
| 12 12 | 
             
                    map %w[vagrant, vvv]             => :vm
         | 
| 13 13 |  | 
| 14 | 
            -
                    class_option : | 
| 14 | 
            +
                    class_option :no_unicode, type: :boolean, alias: "-nu",               desc: "Disable all unicode characters"
         | 
| 15 | 
            +
                    class_option :no_colors,  type: :boolean, alias: "-nc",               desc: "Disable colored output"
         | 
| 16 | 
            +
                    class_option :vvv_path,   type: :string,  alias: "-fp", default: nil, desc: "Force path to VVV installation"
         | 
| 15 17 |  | 
| 16 18 | 
             
                    ###
         | 
| 17 19 | 
             
                    # Non-Thor commands
         | 
| 18 20 | 
             
                    ###
         | 
| 19 21 | 
             
                    no_commands do
         | 
| 20 22 |  | 
| 23 | 
            +
                        ###
         | 
| 24 | 
            +
                        # Disable unicode characters if flag is passed
         | 
| 25 | 
            +
                        #
         | 
| 26 | 
            +
                        # @return {Void}
         | 
| 27 | 
            +
                        ###
         | 
| 28 | 
            +
                        def use_unicode_chars?
         | 
| 29 | 
            +
                            ::ThemeJuice::Utilities.no_unicode = true if options[:no_unicode]
         | 
| 30 | 
            +
                        end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                        ###
         | 
| 33 | 
            +
                        # Disable unicode characters if flag is passed
         | 
| 34 | 
            +
                        #
         | 
| 35 | 
            +
                        # @return {Void}
         | 
| 36 | 
            +
                        ###
         | 
| 37 | 
            +
                        def use_terminal_colors?
         | 
| 38 | 
            +
                            ::ThemeJuice::Utilities.no_colors = true if options[:no_colors]
         | 
| 39 | 
            +
                        end
         | 
| 40 | 
            +
             | 
| 21 41 | 
             
                        ###
         | 
| 22 42 | 
             
                        # Set VVV path
         | 
| 23 43 | 
             
                        #
         | 
| 24 44 | 
             
                        # @return {Void}
         | 
| 25 45 | 
             
                        ###
         | 
| 26 46 | 
             
                        def force_vvv_path?
         | 
| 27 | 
            -
                             | 
| 28 | 
            -
                                ::ThemeJuice::Utilities. | 
| 47 | 
            +
                            if options[:vvv_path].nil?
         | 
| 48 | 
            +
                                ::ThemeJuice::Utilities.vvv_path = File.expand_path("~/vagrant")
         | 
| 49 | 
            +
                            else
         | 
| 50 | 
            +
                                ::ThemeJuice::Utilities.vvv_path = options[:vvv_path]
         | 
| 51 | 
            +
                                ::ThemeJuice::UI.notice "You're using a custom VVV path : (#{::ThemeJuice::Utilities.vvv_path})"
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                                unless ::ThemeJuice::UI.agree? "Is the path correct?"
         | 
| 54 | 
            +
                                    ::ThemeJuice::UI.error "Good call. Let's create a working dev environment, not a broken computer. Aborting mission."
         | 
| 55 | 
            +
                                end
         | 
| 56 | 
            +
                            end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                            unless Dir.exist? ::ThemeJuice::Utilities.vvv_path
         | 
| 59 | 
            +
                                ::ThemeJuice::UI.error "Cannot load VVV path (#{::ThemeJuice::Utilities.vvv_path}). Aborting mission before something bad happens."
         | 
| 29 60 | 
             
                            end
         | 
| 30 61 | 
             
                        end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                        ###
         | 
| 64 | 
            +
                        # Output welcome message
         | 
| 65 | 
            +
                        #
         | 
| 66 | 
            +
                        # @return {Void}
         | 
| 67 | 
            +
                        ###
         | 
| 68 | 
            +
                        def welcome_message
         | 
| 69 | 
            +
                            ::ThemeJuice::UI.success "Welcome to Theme Juice!"
         | 
| 70 | 
            +
                        end
         | 
| 31 71 | 
             
                    end
         | 
| 32 72 |  | 
| 33 73 | 
             
                    ###
         | 
| @@ -39,7 +79,10 @@ module ThemeJuice | |
| 39 79 | 
             
                    def version
         | 
| 40 80 | 
             
                        # ::ThemeJuice::Utilities.check_if_current_version_is_outdated
         | 
| 41 81 |  | 
| 42 | 
            -
                         | 
| 82 | 
            +
                        ::ThemeJuice::UI.speak ::ThemeJuice::VERSION, {
         | 
| 83 | 
            +
                            color: :green,
         | 
| 84 | 
            +
                            icon: :arrow_right
         | 
| 85 | 
            +
                        }
         | 
| 43 86 | 
             
                    end
         | 
| 44 87 |  | 
| 45 88 | 
             
                    ###
         | 
| @@ -63,9 +106,12 @@ module ThemeJuice | |
| 63 106 | 
             
                    method_option :skip_db,      type: :boolean,                                desc: "Skip database prompts and use defaults"
         | 
| 64 107 | 
             
                    method_option :use_defaults, type: :boolean,                                desc: "Skip all promps and use default settings"
         | 
| 65 108 | 
             
                    def create(site = nil)
         | 
| 66 | 
            -
                        self. | 
| 109 | 
            +
                        self.use_terminal_colors?
         | 
| 110 | 
            +
                        self.use_unicode_chars?
         | 
| 67 111 |  | 
| 68 | 
            -
                         | 
| 112 | 
            +
                        self.welcome_message
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                        self.force_vvv_path?
         | 
| 69 115 |  | 
| 70 116 | 
             
                        if options[:site]
         | 
| 71 117 | 
             
                            site = options[:site]
         | 
| @@ -73,20 +119,31 @@ module ThemeJuice | |
| 73 119 |  | 
| 74 120 | 
             
                        # Check if user passed all required options through flags
         | 
| 75 121 | 
             
                        if options.length >= 6 || options[:use_defaults]
         | 
| 76 | 
            -
                             | 
| 122 | 
            +
                            ::ThemeJuice::UI.speak "Well... looks like you just have everything all figured out, huh?", {
         | 
| 123 | 
            +
                                color: [:black, :on_green],
         | 
| 124 | 
            +
                                icon: :arrow_right,
         | 
| 125 | 
            +
                                full_width: true
         | 
| 126 | 
            +
                            }
         | 
| 77 127 | 
             
                        elsif site.nil?
         | 
| 78 | 
            -
                             | 
| 128 | 
            +
                            ::ThemeJuice::UI.speak "Just a few questions before we begin...", {
         | 
| 129 | 
            +
                                color: [:black, :on_green],
         | 
| 130 | 
            +
                                icon: :arrow_right,
         | 
| 131 | 
            +
                                full_width: true
         | 
| 132 | 
            +
                            }
         | 
| 79 133 | 
             
                        else
         | 
| 80 | 
            -
                             | 
| 134 | 
            +
                            ::ThemeJuice::UI.speak "Your site name shall be '#{site}'! Just a few more questions before we begin...", {
         | 
| 135 | 
            +
                                color: [:black, :on_green],
         | 
| 136 | 
            +
                                icon: :arrow_right,
         | 
| 137 | 
            +
                                full_width: true
         | 
| 138 | 
            +
                            }
         | 
| 81 139 | 
             
                        end
         | 
| 82 140 |  | 
| 83 141 | 
             
                        # Ask for the Site name if not passed directly
         | 
| 84 | 
            -
                        site ||=  | 
| 142 | 
            +
                        site ||= ::ThemeJuice::UI.prompt "What's the site name? (only ascii characters are allowed)"
         | 
| 85 143 |  | 
| 86 144 | 
             
                        # Make sure site name is valid
         | 
| 87 145 | 
             
                        if site.match /[^0-9A-Za-z.\-]/
         | 
| 88 | 
            -
                             | 
| 89 | 
            -
                            exit 1
         | 
| 146 | 
            +
                            ::ThemeJuice::UI.error "Site name contains invalid non-ascii characters. This name is used for creating directories, so that's not gonna work. Aborting mission."
         | 
| 90 147 | 
             
                        end
         | 
| 91 148 |  | 
| 92 149 | 
             
                        # Bare install?
         | 
| @@ -103,7 +160,7 @@ module ThemeJuice | |
| 103 160 | 
             
                                if options[:use_defaults]
         | 
| 104 161 | 
             
                                    site_location = "#{Dir.pwd}/"
         | 
| 105 162 | 
             
                                else
         | 
| 106 | 
            -
                                    site_location =  | 
| 163 | 
            +
                                    site_location = ::ThemeJuice::UI.prompt "Where do you want to setup the site?", default: "#{Dir.pwd}/", path: true
         | 
| 107 164 | 
             
                                end
         | 
| 108 165 | 
             
                            end
         | 
| 109 166 |  | 
| @@ -125,16 +182,23 @@ module ThemeJuice | |
| 125 182 | 
             
                                    if options[:use_defaults]
         | 
| 126 183 | 
             
                                        starter_theme = themes["theme-juice/theme-juice-starter"]
         | 
| 127 184 | 
             
                                    else
         | 
| 128 | 
            -
                                         | 
| 185 | 
            +
                                        ::ThemeJuice::UI.speak "Which starter theme would you like to use? (partial name is acceptable)", {
         | 
| 186 | 
            +
                                            color: :blue,
         | 
| 187 | 
            +
                                            icon: :bullet_hollow
         | 
| 188 | 
            +
                                        }
         | 
| 189 | 
            +
             | 
| 129 190 | 
             
                                        choose do |menu|
         | 
| 130 | 
            -
                                            menu.index = "    | 
| 131 | 
            -
                                            menu.prompt = set_color "  | 
| 191 | 
            +
                                            menu.index = "   #{::ThemeJuice::UI::BULLET_HOLLOW}"
         | 
| 192 | 
            +
                                            menu.prompt = set_color " #{::ThemeJuice::UI::ARROW_RIGHT} Choose one :".ljust(16), :blue
         | 
| 132 193 |  | 
| 133 194 | 
             
                                            themes.each do |theme, repo|
         | 
| 134 195 | 
             
                                                menu.choice theme do
         | 
| 135 196 |  | 
| 136 197 | 
             
                                                    if theme == "theme-juice/theme-juice-starter"
         | 
| 137 | 
            -
                                                         | 
| 198 | 
            +
                                                        ::ThemeJuice::UI.speak "Awesome choice!", {
         | 
| 199 | 
            +
                                                            color: :green,
         | 
| 200 | 
            +
                                                            icon: :arrow_up
         | 
| 201 | 
            +
                                                        }
         | 
| 138 202 | 
             
                                                    end
         | 
| 139 203 |  | 
| 140 204 | 
             
                                                    starter_theme = repo
         | 
| @@ -142,11 +206,11 @@ module ThemeJuice | |
| 142 206 | 
             
                                            end
         | 
| 143 207 |  | 
| 144 208 | 
             
                                            menu.choice "other" do
         | 
| 145 | 
            -
                                                starter_theme =  | 
| 209 | 
            +
                                                starter_theme = ::ThemeJuice::UI.prompt "What is the repository URL for the starter theme you would like to clone?", indent: 2
         | 
| 146 210 | 
             
                                            end
         | 
| 147 211 |  | 
| 148 212 | 
             
                                            menu.choice "none" do |opt|
         | 
| 149 | 
            -
                                                 | 
| 213 | 
            +
                                                ::ThemeJuice::UI.notice "Next time you need to create a site without a starter theme, you can just run the 'setup' command instead."
         | 
| 150 214 | 
             
                                                starter_theme, bare_setup = opt, true
         | 
| 151 215 | 
             
                                            end
         | 
| 152 216 | 
             
                                        end
         | 
| @@ -161,13 +225,12 @@ module ThemeJuice | |
| 161 225 | 
             
                                if options[:use_defaults]
         | 
| 162 226 | 
             
                                    dev_url = "#{site}.dev"
         | 
| 163 227 | 
             
                                else
         | 
| 164 | 
            -
                                    dev_url =  | 
| 228 | 
            +
                                    dev_url = ::ThemeJuice::UI.prompt "What do you want the development url to be? (this should end in '.dev')", default: "#{site}.dev"
         | 
| 165 229 | 
             
                                end
         | 
| 166 230 | 
             
                            end
         | 
| 167 231 |  | 
| 168 232 | 
             
                            unless dev_url.match /(.dev)$/
         | 
| 169 | 
            -
                                 | 
| 170 | 
            -
                                exit 1
         | 
| 233 | 
            +
                                ::ThemeJuice::UI.error "Your development url doesn't end with '.dev'. This is used within Vagrant, so that's not gonna work. Aborting mission."
         | 
| 171 234 | 
             
                            end
         | 
| 172 235 |  | 
| 173 236 | 
             
                            # Initialize a git repository on setup
         | 
| @@ -177,8 +240,8 @@ module ThemeJuice | |
| 177 240 | 
             
                                if options[:use_defaults] || options[:skip_repo]
         | 
| 178 241 | 
             
                                    repository = false
         | 
| 179 242 | 
             
                                else
         | 
| 180 | 
            -
                                    if  | 
| 181 | 
            -
                                        repository =  | 
| 243 | 
            +
                                    if ::ThemeJuice::UI.agree? "Would you like to initialize a new Git repository?"
         | 
| 244 | 
            +
                                        repository = ::ThemeJuice::UI.prompt "What is the repository's URL?", indent: 2
         | 
| 182 245 | 
             
                                    else
         | 
| 183 246 | 
             
                                        repository = false
         | 
| 184 247 | 
             
                                    end
         | 
| @@ -189,28 +252,28 @@ module ThemeJuice | |
| 189 252 | 
             
                            if options[:use_defaults] || options[:skip_db]
         | 
| 190 253 | 
             
                                db_host = "vvv"
         | 
| 191 254 | 
             
                            else
         | 
| 192 | 
            -
                                db_host =  | 
| 255 | 
            +
                                db_host = ::ThemeJuice::UI.prompt "Database host", default: "vvv"
         | 
| 193 256 | 
             
                            end
         | 
| 194 257 |  | 
| 195 258 | 
             
                            # Database name
         | 
| 196 259 | 
             
                            if options[:use_defaults] || options[:skip_db]
         | 
| 197 260 | 
             
                                db_name = "#{clean_site_name}_db"
         | 
| 198 261 | 
             
                            else
         | 
| 199 | 
            -
                                db_name =  | 
| 262 | 
            +
                                db_name = ::ThemeJuice::UI.prompt "Database name", default: "#{clean_site_name}_db"
         | 
| 200 263 | 
             
                            end
         | 
| 201 264 |  | 
| 202 265 | 
             
                            # Database username
         | 
| 203 266 | 
             
                            if options[:use_defaults] || options[:skip_db]
         | 
| 204 267 | 
             
                                db_user = "#{clean_site_name}_user"
         | 
| 205 268 | 
             
                            else
         | 
| 206 | 
            -
                                db_user =  | 
| 269 | 
            +
                                db_user = ::ThemeJuice::UI.prompt "Database username", default: "#{clean_site_name}_user"
         | 
| 207 270 | 
             
                            end
         | 
| 208 271 |  | 
| 209 272 | 
             
                            # Database password
         | 
| 210 273 | 
             
                            if options[:use_defaults] || options[:skip_db]
         | 
| 211 274 | 
             
                                db_pass = SecureRandom.base64
         | 
| 212 275 | 
             
                            else
         | 
| 213 | 
            -
                                db_pass =  | 
| 276 | 
            +
                                db_pass = ::ThemeJuice::UI.prompt "Database password", default: SecureRandom.base64
         | 
| 214 277 | 
             
                            end
         | 
| 215 278 |  | 
| 216 279 | 
             
                            # Save options
         | 
| @@ -219,7 +282,7 @@ module ThemeJuice | |
| 219 282 | 
             
                                site_location: File.expand_path(site_location),
         | 
| 220 283 | 
             
                                starter_theme: starter_theme,
         | 
| 221 284 | 
             
                                bare_setup: bare_setup,
         | 
| 222 | 
            -
                                dev_location: File.expand_path("#{::ThemeJuice::Utilities. | 
| 285 | 
            +
                                dev_location: File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/www/tj-#{site}"),
         | 
| 223 286 | 
             
                                dev_url: dev_url,
         | 
| 224 287 | 
             
                                repository: repository,
         | 
| 225 288 | 
             
                                db_host: db_host,
         | 
| @@ -229,27 +292,26 @@ module ThemeJuice | |
| 229 292 | 
             
                            }
         | 
| 230 293 |  | 
| 231 294 | 
             
                            # Verify that all the options are correct
         | 
| 232 | 
            -
                             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 295 | 
            +
                            ::ThemeJuice::UI.list "Your settings :", :yellow, [
         | 
| 296 | 
            +
                                "Site name: #{opts[:site_name]}",
         | 
| 297 | 
            +
                                "Site location: #{opts[:site_location]}",
         | 
| 298 | 
            +
                                "Starter theme: #{opts[:starter_theme]}",
         | 
| 299 | 
            +
                                "Development location: #{opts[:dev_location]}",
         | 
| 300 | 
            +
                                "Development url: http://#{opts[:dev_url]}",
         | 
| 301 | 
            +
                                "Initialized repository: #{opts[:repository]}",
         | 
| 302 | 
            +
                                "Database host: #{opts[:db_host]}",
         | 
| 303 | 
            +
                                "Database name: #{opts[:db_name]}",
         | 
| 304 | 
            +
                                "Database username: #{opts[:db_user]}",
         | 
| 305 | 
            +
                                "Database password: #{opts[:db_pass]}"
         | 
| 306 | 
            +
                            ]
         | 
| 307 | 
            +
             | 
| 308 | 
            +
                            if ::ThemeJuice::UI.agree? "Do the options above look correct?"
         | 
| 245 309 | 
             
                                ::ThemeJuice::Executor::create opts
         | 
| 246 310 | 
             
                            else
         | 
| 247 | 
            -
                                 | 
| 248 | 
            -
                                exit 1
         | 
| 311 | 
            +
                                ::ThemeJuice::UI.error "Dang typos... aborting mission."
         | 
| 249 312 | 
             
                            end
         | 
| 250 313 | 
             
                        else
         | 
| 251 | 
            -
                             | 
| 252 | 
            -
                            exit 1
         | 
| 314 | 
            +
                            ::ThemeJuice::UI.error "Site name is required. Aborting mission."
         | 
| 253 315 | 
             
                        end
         | 
| 254 316 | 
             
                    end
         | 
| 255 317 |  | 
| @@ -277,10 +339,17 @@ module ThemeJuice | |
| 277 339 | 
             
                    desc "delete SITE", "Remove SITE from the VVV development environment (does not remove local site)"
         | 
| 278 340 | 
             
                    method_option :restart, type: :boolean
         | 
| 279 341 | 
             
                    def delete(site)
         | 
| 342 | 
            +
                        self.use_terminal_colors?
         | 
| 343 | 
            +
                        self.use_unicode_chars?
         | 
| 280 344 | 
             
                        self.force_vvv_path?
         | 
| 281 345 |  | 
| 282 | 
            -
                         | 
| 283 | 
            -
             | 
| 346 | 
            +
                        ::ThemeJuice::UI.speak "Are you sure you want to delete '#{site}'? (y/N)", {
         | 
| 347 | 
            +
                            color: [:white, :on_red],
         | 
| 348 | 
            +
                            icon: :arrow_right,
         | 
| 349 | 
            +
                            full_width: true
         | 
| 350 | 
            +
                        }
         | 
| 351 | 
            +
             | 
| 352 | 
            +
                        if ::ThemeJuice::UI.agree? "", { color: :red, simple: true }
         | 
| 284 353 | 
             
                            ::ThemeJuice::Executor::delete site, options[:restart]
         | 
| 285 354 | 
             
                        end
         | 
| 286 355 | 
             
                    end
         | 
| @@ -292,6 +361,8 @@ module ThemeJuice | |
| 292 361 | 
             
                    ###
         | 
| 293 362 | 
             
                    desc "list", "List all sites within the VVV development environment"
         | 
| 294 363 | 
             
                    def list
         | 
| 364 | 
            +
                        self.use_terminal_colors?
         | 
| 365 | 
            +
                        self.use_unicode_chars?
         | 
| 295 366 | 
             
                        self.force_vvv_path?
         | 
| 296 367 |  | 
| 297 368 | 
             
                        ::ThemeJuice::Executor::list
         | 
| @@ -305,6 +376,9 @@ module ThemeJuice | |
| 305 376 | 
             
                    desc "install", "Run installation for the starter theme"
         | 
| 306 377 | 
             
                    method_option :config, type: :string, aliases: "-c", default: nil, desc: "Force path to config file"
         | 
| 307 378 | 
             
                    def install
         | 
| 379 | 
            +
                        self.use_terminal_colors?
         | 
| 380 | 
            +
                        self.use_unicode_chars?
         | 
| 381 | 
            +
             | 
| 308 382 | 
             
                        ::ThemeJuice::Executor::install options[:config]
         | 
| 309 383 | 
             
                    end
         | 
| 310 384 |  | 
| @@ -318,6 +392,9 @@ module ThemeJuice | |
| 318 392 | 
             
                    ###
         | 
| 319 393 | 
             
                    desc "watch [COMMANDS]", "Watch and compile assets"
         | 
| 320 394 | 
             
                    def watch(*commands)
         | 
| 395 | 
            +
                        self.use_terminal_colors?
         | 
| 396 | 
            +
                        self.use_unicode_chars?
         | 
| 397 | 
            +
             | 
| 321 398 | 
             
                        ::ThemeJuice::Executor::subcommand "#{__method__}", commands.join(" ")
         | 
| 322 399 | 
             
                    end
         | 
| 323 400 |  | 
| @@ -331,6 +408,9 @@ module ThemeJuice | |
| 331 408 | 
             
                    ###
         | 
| 332 409 | 
             
                    desc "vendor [COMMANDS]", "Manage vendor dependencies"
         | 
| 333 410 | 
             
                    def vendor(*commands)
         | 
| 411 | 
            +
                        self.use_terminal_colors?
         | 
| 412 | 
            +
                        self.use_unicode_chars?
         | 
| 413 | 
            +
             | 
| 334 414 | 
             
                        ::ThemeJuice::Executor::subcommand "#{__method__}", commands.join(" ")
         | 
| 335 415 | 
             
                    end
         | 
| 336 416 |  | 
| @@ -344,6 +424,8 @@ module ThemeJuice | |
| 344 424 | 
             
                    ###
         | 
| 345 425 | 
             
                    desc "server [COMMANDS]", "Manage deployment and migration"
         | 
| 346 426 | 
             
                    def server(*commands)
         | 
| 427 | 
            +
                        self.use_terminal_colors?
         | 
| 428 | 
            +
                        self.use_unicode_chars?
         | 
| 347 429 | 
             
                        self.force_vvv_path?
         | 
| 348 430 |  | 
| 349 431 | 
             
                        ::ThemeJuice::Executor::subcommand "#{__method__}", commands.join(" ")
         | 
| @@ -359,9 +441,11 @@ module ThemeJuice | |
| 359 441 | 
             
                    ###
         | 
| 360 442 | 
             
                    desc "vm [COMMANDS]", "Manage virtual development environment with Vagrant"
         | 
| 361 443 | 
             
                    def vm(*commands)
         | 
| 444 | 
            +
                        self.use_terminal_colors?
         | 
| 445 | 
            +
                        self.use_unicode_chars?
         | 
| 362 446 | 
             
                        self.force_vvv_path?
         | 
| 363 447 |  | 
| 364 | 
            -
                        system "cd #{::ThemeJuice::Utilities. | 
| 448 | 
            +
                        system "cd #{::ThemeJuice::Utilities.vvv_path} && vagrant #{commands.join(" ")}"
         | 
| 365 449 | 
             
                    end
         | 
| 366 450 | 
             
                end
         | 
| 367 451 | 
             
            end
         | 
    
        data/lib/theme-juice/executor.rb
    CHANGED
    
    | @@ -37,8 +37,7 @@ module ThemeJuice | |
| 37 37 | 
             
                            if @config[subcommand]
         | 
| 38 38 | 
             
                                run ["#{@config[subcommand]} #{commands}"], false
         | 
| 39 39 | 
             
                            else
         | 
| 40 | 
            -
                                 | 
| 41 | 
            -
                                exit 1
         | 
| 40 | 
            +
                                ::ThemeJuice::UI.error "Unable to find '#{subcommand}' command in '#{config_path}/tj-config.yml'. Aborting mission."
         | 
| 42 41 | 
             
                            end
         | 
| 43 42 | 
             
                        end
         | 
| 44 43 |  | 
| @@ -52,7 +51,7 @@ module ThemeJuice | |
| 52 51 | 
             
                        def create(opts)
         | 
| 53 52 | 
             
                            @opts = opts
         | 
| 54 53 |  | 
| 55 | 
            -
                             | 
| 54 | 
            +
                            ::ThemeJuice::UI.notice "Running setup for '#{@opts[:site_name]}'..."
         | 
| 56 55 |  | 
| 57 56 | 
             
                            unless project_dir_is_setup?
         | 
| 58 57 | 
             
                                setup_project_dir
         | 
| @@ -109,37 +108,44 @@ module ThemeJuice | |
| 109 108 | 
             
                            end
         | 
| 110 109 |  | 
| 111 110 | 
             
                            if setup_was_successful?
         | 
| 112 | 
            -
                                 | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
                                     | 
| 111 | 
            +
                                ::ThemeJuice::UI.success "Setup complete!"
         | 
| 112 | 
            +
                                ::ThemeJuice::UI.speak "In order to finish creating your site, you need to provision Vagrant. Do it now? (y/N)", {
         | 
| 113 | 
            +
                                    color: [:black, :on_blue],
         | 
| 114 | 
            +
                                    icon: :arrow_reload,
         | 
| 115 | 
            +
                                    full_width: true
         | 
| 116 | 
            +
                                }
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                                if ::ThemeJuice::UI.agree? "", { simple: true }
         | 
| 119 | 
            +
                                    ::ThemeJuice::UI.speak "Restarting VVV...", {
         | 
| 120 | 
            +
                                        color: :yellow,
         | 
| 121 | 
            +
                                        icon: :bullet_solid
         | 
| 122 | 
            +
                                    }
         | 
| 117 123 |  | 
| 118 124 | 
             
                                    if restart_vagrant
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                                        # Output success message
         | 
| 121 | 
            -
                                        say " Success!".ljust(terminal_width), [:black, :on_green, :bold]
         | 
| 125 | 
            +
                                        ::ThemeJuice::UI.success "Success!"
         | 
| 122 126 |  | 
| 123 127 | 
             
                                        # Output setup info
         | 
| 124 | 
            -
                                         | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 128 | 
            +
                                        ::ThemeJuice::UI.list "Your settings :", :blue, [
         | 
| 129 | 
            +
                                            "Site name: #{@opts[:site_name]}",
         | 
| 130 | 
            +
                                            "Site location: #{@opts[:site_location]}",
         | 
| 131 | 
            +
                                            "Starter theme: #{@opts[:starter_theme]}",
         | 
| 132 | 
            +
                                            "Development location: #{@opts[:dev_location]}",
         | 
| 133 | 
            +
                                            "Development url: http://#{@opts[:dev_url]}",
         | 
| 134 | 
            +
                                            "Initialized repository: #{@opts[:repository]}",
         | 
| 135 | 
            +
                                            "Database host: #{@opts[:db_host]}",
         | 
| 136 | 
            +
                                            "Database name: #{@opts[:db_name]}",
         | 
| 137 | 
            +
                                            "Database username: #{@opts[:db_user]}",
         | 
| 138 | 
            +
                                            "Database password: #{@opts[:db_pass]}"
         | 
| 139 | 
            +
                                        ]
         | 
| 135 140 | 
             
                                    end
         | 
| 136 141 | 
             
                                else
         | 
| 137 | 
            -
                                     | 
| 142 | 
            +
                                    ::ThemeJuice::UI.notice "Remember, Vagrant needs to be provisioned before you can use your new site. Exiting..."
         | 
| 138 143 | 
             
                                    exit
         | 
| 139 144 | 
             
                                end
         | 
| 140 145 | 
             
                            else
         | 
| 141 | 
            -
                                 | 
| 142 | 
            -
             | 
| 146 | 
            +
                                ::ThemeJuice::UI.error "Setup failed. Running cleanup..." do
         | 
| 147 | 
            +
                                    delete @opts[:site_name], false
         | 
| 148 | 
            +
                                end
         | 
| 143 149 | 
             
                            end
         | 
| 144 150 | 
             
                        end
         | 
| 145 151 |  | 
| @@ -159,14 +165,13 @@ module ThemeJuice | |
| 159 165 | 
             
                            ###
         | 
| 160 166 | 
             
                            @opts = {
         | 
| 161 167 | 
             
                                site_name: site,
         | 
| 162 | 
            -
                                dev_location: File.expand_path("#{::ThemeJuice::Utilities. | 
| 168 | 
            +
                                dev_location: File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/www/tj-#{site}")
         | 
| 163 169 | 
             
                            }
         | 
| 164 170 |  | 
| 165 171 | 
             
                            if dev_site_is_setup?
         | 
| 166 172 | 
             
                                remove_dev_site
         | 
| 167 173 | 
             
                            else
         | 
| 168 | 
            -
                                 | 
| 169 | 
            -
                                exit 1
         | 
| 174 | 
            +
                                ::ThemeJuice::UI.error "Site '#{@opts[:site_name]}' does not exist."
         | 
| 170 175 | 
             
                            end
         | 
| 171 176 |  | 
| 172 177 | 
             
                            if database_is_setup?
         | 
| @@ -178,15 +183,18 @@ module ThemeJuice | |
| 178 183 | 
             
                            end
         | 
| 179 184 |  | 
| 180 185 | 
             
                            if removal_was_successful?
         | 
| 181 | 
            -
                                 | 
| 186 | 
            +
                                ::ThemeJuice::UI.success "Site '#{@opts[:site_name]}' successfully removed!"
         | 
| 182 187 |  | 
| 183 188 | 
             
                                if restart
         | 
| 184 | 
            -
                                     | 
| 189 | 
            +
                                    ::ThemeJuice::UI.speak "Restarting VVV...", {
         | 
| 190 | 
            +
                                        color: :yellow,
         | 
| 191 | 
            +
                                        icon: :bullet_solid
         | 
| 192 | 
            +
                                    }
         | 
| 193 | 
            +
             | 
| 185 194 | 
             
                                    restart_vagrant
         | 
| 186 195 | 
             
                                end
         | 
| 187 196 | 
             
                            else
         | 
| 188 | 
            -
                                 | 
| 189 | 
            -
                                exit 1
         | 
| 197 | 
            +
                                ::ThemeJuice::UI.error "'#{@opts[:site_name]}' could not be fully be removed."
         | 
| 190 198 | 
             
                            end
         | 
| 191 199 | 
             
                        end
         | 
| 192 200 |  | 
| @@ -198,15 +206,17 @@ module ThemeJuice | |
| 198 206 | 
             
                        def list
         | 
| 199 207 | 
             
                            sites = []
         | 
| 200 208 |  | 
| 201 | 
            -
                            Dir.glob(File.expand_path("#{::ThemeJuice::Utilities. | 
| 209 | 
            +
                            Dir.glob(File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/www/*")).each do |f|
         | 
| 202 210 | 
             
                                sites << File.basename(f).gsub(/(tj-)/, "") if File.directory?(f) && f.include?("tj-")
         | 
| 203 211 | 
             
                            end
         | 
| 204 212 |  | 
| 205 213 | 
             
                            if sites.empty?
         | 
| 206 | 
            -
                                 | 
| 214 | 
            +
                                ::ThemeJuice::UI.speak "Nothing to list. Why haven't you created a site yet?", {
         | 
| 215 | 
            +
                                    color: :yellow,
         | 
| 216 | 
            +
                                    icon: :bullet_solid
         | 
| 217 | 
            +
                                }
         | 
| 207 218 | 
             
                            else
         | 
| 208 | 
            -
                                 | 
| 209 | 
            -
                                sites.each_with_index { |site, i| say " ● #{site}", :blue }
         | 
| 219 | 
            +
                                ::ThemeJuice::UI.list "Your sites :", :green, sites
         | 
| 210 220 | 
             
                            end
         | 
| 211 221 |  | 
| 212 222 | 
             
                            sites
         | 
| @@ -241,21 +251,20 @@ module ThemeJuice | |
| 241 251 | 
             
                            if config_is_setup? config_path
         | 
| 242 252 | 
             
                                @config = YAML.load_file "#{config_path}/tj-config.yml"
         | 
| 243 253 | 
             
                            else
         | 
| 244 | 
            -
                                 | 
| 254 | 
            +
                                ::ThemeJuice::UI.notice "Unable to find 'tj-config.yml' file in '#{config_path}'."
         | 
| 245 255 |  | 
| 246 | 
            -
                                if  | 
| 256 | 
            +
                                if ::ThemeJuice::UI.agree? "Would you like to create one?"
         | 
| 247 257 |  | 
| 248 258 | 
             
                                    setup_config(config_path)
         | 
| 249 259 |  | 
| 250 260 | 
             
                                    if config_is_setup? config_path
         | 
| 251 | 
            -
                                         | 
| 261 | 
            +
                                        ::ThemeJuice::UI.notice "Please re-run the last command to continue."
         | 
| 252 262 | 
             
                                        exit
         | 
| 253 263 | 
             
                                    else
         | 
| 254 264 | 
             
                                        exit 1
         | 
| 255 265 | 
             
                                    end
         | 
| 256 266 | 
             
                                else
         | 
| 257 | 
            -
                                     | 
| 258 | 
            -
                                    exit 1
         | 
| 267 | 
            +
                                    ::ThemeJuice::UI.error "A config file is needed to continue. Aborting mission."
         | 
| 259 268 | 
             
                                end
         | 
| 260 269 | 
             
                            end
         | 
| 261 270 | 
             
                        end
         | 
| @@ -270,7 +279,7 @@ module ThemeJuice | |
| 270 279 | 
             
                        ###
         | 
| 271 280 | 
             
                        def restart_vagrant
         | 
| 272 281 | 
             
                            run [
         | 
| 273 | 
            -
                                "cd #{::ThemeJuice::Utilities. | 
| 282 | 
            +
                                "cd #{::ThemeJuice::Utilities.vvv_path}",
         | 
| 274 283 | 
             
                                "vagrant halt",
         | 
| 275 284 | 
             
                                "vagrant up --provision",
         | 
| 276 285 | 
             
                            ], false
         | 
| @@ -308,14 +317,14 @@ module ThemeJuice | |
| 308 317 | 
             
                        # @return {Bool}
         | 
| 309 318 | 
             
                        ###
         | 
| 310 319 | 
             
                        def vvv_is_setup?
         | 
| 311 | 
            -
                            File.exist? File.expand_path(::ThemeJuice::Utilities. | 
| 320 | 
            +
                            File.exist? File.expand_path(::ThemeJuice::Utilities.vvv_path)
         | 
| 312 321 | 
             
                        end
         | 
| 313 322 |  | 
| 314 323 | 
             
                        ###
         | 
| 315 324 | 
             
                        # @return {Bool}
         | 
| 316 325 | 
             
                        ###
         | 
| 317 326 | 
             
                        def wildcard_subdomains_is_setup?
         | 
| 318 | 
            -
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities. | 
| 327 | 
            +
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile")).grep(/(config.landrush.enabled = true)/m).any?
         | 
| 319 328 | 
             
                        end
         | 
| 320 329 |  | 
| 321 330 | 
             
                        ###
         | 
| @@ -336,7 +345,7 @@ module ThemeJuice | |
| 336 345 | 
             
                        # @return {Bool}
         | 
| 337 346 | 
             
                        ###
         | 
| 338 347 | 
             
                        def database_is_setup?
         | 
| 339 | 
            -
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities. | 
| 348 | 
            +
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql")).grep(/(### Begin '#{@opts[:site_name]}')/m).any?
         | 
| 340 349 | 
             
                        end
         | 
| 341 350 |  | 
| 342 351 | 
             
                        ###
         | 
| @@ -357,7 +366,7 @@ module ThemeJuice | |
| 357 366 | 
             
                        # @return {Bool}
         | 
| 358 367 | 
             
                        ###
         | 
| 359 368 | 
             
                        def synced_folder_is_setup?
         | 
| 360 | 
            -
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities. | 
| 369 | 
            +
                            File.readlines(File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile")).grep(/(### Begin '#{@opts[:site_name]}')/m).any?
         | 
| 361 370 | 
             
                        end
         | 
| 362 371 |  | 
| 363 372 | 
             
                        ###
         | 
| @@ -387,13 +396,17 @@ module ThemeJuice | |
| 387 396 | 
             
                        # @return {Void}
         | 
| 388 397 | 
             
                        ###
         | 
| 389 398 | 
             
                        def setup_vvv
         | 
| 390 | 
            -
                             | 
| 399 | 
            +
                            ::ThemeJuice::UI.speak "Installing VVV into '#{File.expand_path("#{::ThemeJuice::Utilities.vvv_path}")}'...", {
         | 
| 400 | 
            +
                                color: :yellow,
         | 
| 401 | 
            +
                                icon: :bullet_solid
         | 
| 402 | 
            +
                            }
         | 
| 403 | 
            +
             | 
| 391 404 | 
             
                            run [
         | 
| 392 405 | 
             
                                "vagrant plugin install vagrant-hostsupdater",
         | 
| 393 406 | 
             
                                "vagrant plugin install vagrant-triggers",
         | 
| 394 407 | 
             
                                "vagrant plugin install landrush",
         | 
| 395 | 
            -
                                "git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git #{::ThemeJuice::Utilities. | 
| 396 | 
            -
                                "cd #{::ThemeJuice::Utilities. | 
| 408 | 
            +
                                "git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git #{::ThemeJuice::Utilities.vvv_path}",
         | 
| 409 | 
            +
                                "cd #{::ThemeJuice::Utilities.vvv_path}/database && touch init-custom.sql"
         | 
| 397 410 | 
             
                            ]
         | 
| 398 411 | 
             
                        end
         | 
| 399 412 |  | 
| @@ -403,7 +416,11 @@ module ThemeJuice | |
| 403 416 | 
             
                        # @return {Void}
         | 
| 404 417 | 
             
                        ###
         | 
| 405 418 | 
             
                        def setup_project_dir
         | 
| 406 | 
            -
                             | 
| 419 | 
            +
                            ::ThemeJuice::UI.speak "Creating project directory tree in '#{@opts[:site_location]}'...", {
         | 
| 420 | 
            +
                                color: :yellow,
         | 
| 421 | 
            +
                                icon: :bullet_solid
         | 
| 422 | 
            +
                            }
         | 
| 423 | 
            +
             | 
| 407 424 | 
             
                            run ["mkdir -p #{@opts[:site_location]}"]
         | 
| 408 425 | 
             
                        end
         | 
| 409 426 |  | 
| @@ -416,8 +433,12 @@ module ThemeJuice | |
| 416 433 | 
             
                        # @return {Void}
         | 
| 417 434 | 
             
                        ###
         | 
| 418 435 | 
             
                        def setup_wildcard_subdomains
         | 
| 419 | 
            -
                             | 
| 420 | 
            -
             | 
| 436 | 
            +
                            ::ThemeJuice::UI.speak "Setting up wildcard subdomains...", {
         | 
| 437 | 
            +
                                color: :yellow,
         | 
| 438 | 
            +
                                icon: :bullet_solid
         | 
| 439 | 
            +
                            }
         | 
| 440 | 
            +
             | 
| 441 | 
            +
                            open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "a+" do |file|
         | 
| 421 442 | 
             
                                file.puts "\n"
         | 
| 422 443 | 
             
                                file.puts "###"
         | 
| 423 444 | 
             
                                file.puts "# Enable wildcard subdomains"
         | 
| @@ -438,9 +459,13 @@ module ThemeJuice | |
| 438 459 | 
             
                        # @return {Void}
         | 
| 439 460 | 
             
                        ###
         | 
| 440 461 | 
             
                        def setup_dev_site
         | 
| 441 | 
            -
                             | 
| 462 | 
            +
                            ::ThemeJuice::UI.speak "Setting up new development site at '#{@opts[:dev_location]}'...", {
         | 
| 463 | 
            +
                                color: :yellow,
         | 
| 464 | 
            +
                                icon: :bullet_solid
         | 
| 465 | 
            +
                            }
         | 
| 466 | 
            +
             | 
| 442 467 | 
             
                            run [
         | 
| 443 | 
            -
                                "cd #{::ThemeJuice::Utilities. | 
| 468 | 
            +
                                "cd #{::ThemeJuice::Utilities.vvv_path}/www",
         | 
| 444 469 | 
             
                                "mkdir tj-#{@opts[:site_name]}",
         | 
| 445 470 | 
             
                            ]
         | 
| 446 471 | 
             
                        end
         | 
| @@ -453,10 +478,10 @@ module ThemeJuice | |
| 453 478 | 
             
                        # @return {Void}
         | 
| 454 479 | 
             
                        ###
         | 
| 455 480 | 
             
                        def setup_config(config_path)
         | 
| 456 | 
            -
                            watch | 
| 457 | 
            -
                            server | 
| 458 | 
            -
                            vendor | 
| 459 | 
            -
                            install =  | 
| 481 | 
            +
                            watch   = ::ThemeJuice::UI.prompt "Watch command to use",             indent: 2, default: "bundle exec guard"
         | 
| 482 | 
            +
                            server  = ::ThemeJuice::UI.prompt "Deployment command to use",        indent: 2, default: "bundle exec cap"
         | 
| 483 | 
            +
                            vendor  = ::ThemeJuice::UI.prompt "Vendor command to use",            indent: 2, default: "composer"
         | 
| 484 | 
            +
                            install = ::ThemeJuice::UI.prompt "Commands to run on theme install", indent: 2, default: "composer install"
         | 
| 460 485 |  | 
| 461 486 | 
             
                            File.open "#{config_path}/tj-config.yml", "w" do |file|
         | 
| 462 487 | 
             
                                file.puts "watch: #{watch}"
         | 
| @@ -467,9 +492,12 @@ module ThemeJuice | |
| 467 492 | 
             
                            end
         | 
| 468 493 |  | 
| 469 494 | 
             
                            if config_is_setup? config_path
         | 
| 470 | 
            -
                                 | 
| 495 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added 'tj-config.yml' file.", {
         | 
| 496 | 
            +
                                    color: :green,
         | 
| 497 | 
            +
                                    icon: :bullet_solid
         | 
| 498 | 
            +
                                }
         | 
| 471 499 | 
             
                            else
         | 
| 472 | 
            -
                                 | 
| 500 | 
            +
                                ::ThemeJuice::UI.error "Could not create 'tj-config.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 473 501 | 
             
                            end
         | 
| 474 502 | 
             
                        end
         | 
| 475 503 |  | 
| @@ -484,9 +512,12 @@ module ThemeJuice | |
| 484 512 | 
             
                            end
         | 
| 485 513 |  | 
| 486 514 | 
             
                            if hosts_is_setup?
         | 
| 487 | 
            -
                                 | 
| 515 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added 'vvv-hosts' file.", {
         | 
| 516 | 
            +
                                    color: :green,
         | 
| 517 | 
            +
                                    icon: :bullet_solid
         | 
| 518 | 
            +
                                }
         | 
| 488 519 | 
             
                            else
         | 
| 489 | 
            -
                                 | 
| 520 | 
            +
                                ::ThemeJuice::UI.error "Could not create 'vvv-hosts' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 490 521 | 
             
                            end
         | 
| 491 522 | 
             
                        end
         | 
| 492 523 |  | 
| @@ -496,7 +527,7 @@ module ThemeJuice | |
| 496 527 | 
             
                        # @return {Void}
         | 
| 497 528 | 
             
                        ###
         | 
| 498 529 | 
             
                        def setup_database
         | 
| 499 | 
            -
                            File.open File.expand_path("#{::ThemeJuice::Utilities. | 
| 530 | 
            +
                            File.open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql"), "a+" do |file|
         | 
| 500 531 | 
             
                                file.puts "### Begin '#{@opts[:site_name]}'"
         | 
| 501 532 | 
             
                                file.puts "#"
         | 
| 502 533 | 
             
                                file.puts "# This block is automatically generated by ThemeJuice. Do not edit."
         | 
| @@ -508,9 +539,12 @@ module ThemeJuice | |
| 508 539 | 
             
                            end
         | 
| 509 540 |  | 
| 510 541 | 
             
                            if database_is_setup?
         | 
| 511 | 
            -
                                 | 
| 542 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added database to 'init-custom.sql'.", {
         | 
| 543 | 
            +
                                    color: :green,
         | 
| 544 | 
            +
                                    icon: :bullet_solid
         | 
| 545 | 
            +
                                }
         | 
| 512 546 | 
             
                            else
         | 
| 513 | 
            -
                                 | 
| 547 | 
            +
                                ::ThemeJuice::UI.error "Could not add database info for '#{@opts[:site_name]}' to 'init-custom.sql'. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 514 548 | 
             
                            end
         | 
| 515 549 | 
             
                        end
         | 
| 516 550 |  | 
| @@ -530,9 +564,12 @@ module ThemeJuice | |
| 530 564 | 
             
                            end
         | 
| 531 565 |  | 
| 532 566 | 
             
                            if nginx_is_setup?
         | 
| 533 | 
            -
                                 | 
| 567 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added 'vvv-nginx.conf' file.", {
         | 
| 568 | 
            +
                                    color: :green,
         | 
| 569 | 
            +
                                    icon: :bullet_solid
         | 
| 570 | 
            +
                                }
         | 
| 534 571 | 
             
                            else
         | 
| 535 | 
            -
                                 | 
| 572 | 
            +
                                ::ThemeJuice::UI.error "Could not create 'vvv-nginx.conf' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 536 573 | 
             
                            end
         | 
| 537 574 | 
             
                        end
         | 
| 538 575 |  | 
| @@ -552,9 +589,12 @@ module ThemeJuice | |
| 552 589 | 
             
                            end
         | 
| 553 590 |  | 
| 554 591 | 
             
                            if env_is_setup?
         | 
| 555 | 
            -
                                 | 
| 592 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added '.env.development' file.", {
         | 
| 593 | 
            +
                                    color: :green,
         | 
| 594 | 
            +
                                    icon: :bullet_solid
         | 
| 595 | 
            +
                                }
         | 
| 556 596 | 
             
                            else
         | 
| 557 | 
            -
                                 | 
| 597 | 
            +
                                ::ThemeJuice::UI.error "Could not create '.env.development' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 558 598 | 
             
                            end
         | 
| 559 599 | 
             
                        end
         | 
| 560 600 |  | 
| @@ -566,7 +606,10 @@ module ThemeJuice | |
| 566 606 | 
             
                        # @return {Void}
         | 
| 567 607 | 
             
                        ###
         | 
| 568 608 | 
             
                        def setup_wordpress
         | 
| 569 | 
            -
                             | 
| 609 | 
            +
                            ::ThemeJuice::UI.speak "Setting up WordPress...", {
         | 
| 610 | 
            +
                                color: :yellow,
         | 
| 611 | 
            +
                                icon: :bullet_solid
         | 
| 612 | 
            +
                            }
         | 
| 570 613 |  | 
| 571 614 | 
             
                            unless @opts[:bare_setup]
         | 
| 572 615 | 
             
                                run [
         | 
| @@ -582,7 +625,10 @@ module ThemeJuice | |
| 582 625 | 
             
                        # @return {Void}
         | 
| 583 626 | 
             
                        ###
         | 
| 584 627 | 
             
                        def install_theme_dependencies
         | 
| 585 | 
            -
                             | 
| 628 | 
            +
                            ::ThemeJuice::UI.speak "Installing theme dependencies...", {
         | 
| 629 | 
            +
                                color: :yellow,
         | 
| 630 | 
            +
                                icon: :bullet_solid
         | 
| 631 | 
            +
                            }
         | 
| 586 632 |  | 
| 587 633 | 
             
                            @config["install"].each do |command|
         | 
| 588 634 | 
             
                                run ["cd #{@opts[:site_location]}", command], false
         | 
| @@ -595,9 +641,12 @@ module ThemeJuice | |
| 595 641 | 
             
                        # @return {Void}
         | 
| 596 642 | 
             
                        ###
         | 
| 597 643 | 
             
                        def setup_synced_folder
         | 
| 598 | 
            -
                             | 
| 644 | 
            +
                            ::ThemeJuice::UI.speak "Syncing host theme directory '#{@opts[:site_location]}' with VM theme directory '/srv/www/tj-#{@opts[:site_name]}'...", {
         | 
| 645 | 
            +
                                color: :yellow,
         | 
| 646 | 
            +
                                icon: :bullet_solid
         | 
| 647 | 
            +
                            }
         | 
| 599 648 |  | 
| 600 | 
            -
                            open File.expand_path("#{::ThemeJuice::Utilities. | 
| 649 | 
            +
                            open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "a+" do |file|
         | 
| 601 650 | 
             
                                file.puts "### Begin '#{@opts[:site_name]}'"
         | 
| 602 651 | 
             
                                file.puts "#"
         | 
| 603 652 | 
             
                                file.puts "# This block is automatically generated by ThemeJuice. Do not edit."
         | 
| @@ -617,7 +666,10 @@ module ThemeJuice | |
| 617 666 | 
             
                        # @return {Void}
         | 
| 618 667 | 
             
                        ###
         | 
| 619 668 | 
             
                        def setup_repo
         | 
| 620 | 
            -
                             | 
| 669 | 
            +
                            ::ThemeJuice::UI.speak "Setting up Git repository at '#{@opts[:repository]}'...", {
         | 
| 670 | 
            +
                                color: :yellow,
         | 
| 671 | 
            +
                                icon: :bullet_solid
         | 
| 672 | 
            +
                            }
         | 
| 621 673 |  | 
| 622 674 | 
             
                            if repo_is_setup?
         | 
| 623 675 | 
             
                                run [
         | 
| @@ -646,14 +698,17 @@ module ThemeJuice | |
| 646 698 | 
             
                                file.puts "\tvagrant:"
         | 
| 647 699 | 
             
                                file.puts "\t\turl: #{@opts[:dev_url]}"
         | 
| 648 700 | 
             
                                file.puts "\t\tpath: /srv/www/tj-#{@opts[:site_name]}"
         | 
| 649 | 
            -
                                file.puts "\t\tcmd: cd #{::ThemeJuice::Utilities. | 
| 701 | 
            +
                                file.puts "\t\tcmd: cd #{::ThemeJuice::Utilities.vvv_path} && vagrant ssh-config > /tmp/vagrant_ssh_config && ssh -q %pseudotty% -F /tmp/vagrant_ssh_config default %cmd%"
         | 
| 650 702 | 
             
                                file.puts "\n"
         | 
| 651 703 | 
             
                            end
         | 
| 652 704 |  | 
| 653 705 | 
             
                            if wpcli_is_setup?
         | 
| 654 | 
            -
                                 | 
| 706 | 
            +
                                ::ThemeJuice::UI.speak "Successfully added ssh settings to 'wp-cli.local.yml' file.", {
         | 
| 707 | 
            +
                                    color: :green,
         | 
| 708 | 
            +
                                    icon: :bullet_solid
         | 
| 709 | 
            +
                                }
         | 
| 655 710 | 
             
                            else
         | 
| 656 | 
            -
                                 | 
| 711 | 
            +
                                ::ThemeJuice::UI.error "Could not create 'wp-cli.local.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
         | 
| 657 712 | 
             
                            end
         | 
| 658 713 | 
             
                        end
         | 
| 659 714 |  | 
| @@ -664,15 +719,18 @@ module ThemeJuice | |
| 664 719 | 
             
                        ###
         | 
| 665 720 | 
             
                        def remove_dev_site
         | 
| 666 721 |  | 
| 667 | 
            -
                            unless Dir.entries("#{::ThemeJuice::Utilities. | 
| 722 | 
            +
                            unless Dir.entries("#{::ThemeJuice::Utilities.vvv_path}").include? "www"
         | 
| 668 723 | 
             
                                say " ↑ Cannot load VVV path. Aborting mission before something bad happens.".ljust(terminal_width), [:white, :on_red]
         | 
| 669 724 | 
             
                                exit 1
         | 
| 670 725 | 
             
                            end
         | 
| 671 726 |  | 
| 672 727 | 
             
                            if run ["rm -rf #{@opts[:dev_location]}"]
         | 
| 673 | 
            -
                                 | 
| 728 | 
            +
                                ::ThemeJuice::UI.speak "VVV installation for '#{@opts[:site_name]}' successfully removed.", {
         | 
| 729 | 
            +
                                    color: :green,
         | 
| 730 | 
            +
                                    icon: :bullet_solid
         | 
| 731 | 
            +
                                }
         | 
| 674 732 | 
             
                            else
         | 
| 675 | 
            -
                                 | 
| 733 | 
            +
                                ::ThemeJuice::UI.error "Theme '#{@opts[:site_name]}' could not be removed. Make sure you have write capabilities to '#{@opts[:dev_location]}'."
         | 
| 676 734 | 
             
                            end
         | 
| 677 735 | 
             
                        end
         | 
| 678 736 |  | 
| @@ -682,8 +740,11 @@ module ThemeJuice | |
| 682 740 | 
             
                        # @return {Void}
         | 
| 683 741 | 
             
                        ###
         | 
| 684 742 | 
             
                        def remove_database
         | 
| 685 | 
            -
                            if remove_traces_from_file "#{::ThemeJuice::Utilities. | 
| 686 | 
            -
                                 | 
| 743 | 
            +
                            if remove_traces_from_file "#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql"
         | 
| 744 | 
            +
                                ::ThemeJuice::UI.speak "Database for '#{@opts[:site_name]}' successfully removed.", {
         | 
| 745 | 
            +
                                    color: :yellow,
         | 
| 746 | 
            +
                                    icon: :bullet_solid
         | 
| 747 | 
            +
                                }
         | 
| 687 748 | 
             
                            end
         | 
| 688 749 | 
             
                        end
         | 
| 689 750 |  | 
| @@ -693,8 +754,11 @@ module ThemeJuice | |
| 693 754 | 
             
                        # @return {Void}
         | 
| 694 755 | 
             
                        ###
         | 
| 695 756 | 
             
                        def remove_synced_folder
         | 
| 696 | 
            -
                            if remove_traces_from_file "#{::ThemeJuice::Utilities. | 
| 697 | 
            -
                                 | 
| 757 | 
            +
                            if remove_traces_from_file "#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"
         | 
| 758 | 
            +
                                ::ThemeJuice::UI.speak "Synced folders for '#{@opts[:site_name]}' successfully removed.", {
         | 
| 759 | 
            +
                                    color: :yellow,
         | 
| 760 | 
            +
                                    icon: :bullet_solid
         | 
| 761 | 
            +
                                }
         | 
| 698 762 | 
             
                            end
         | 
| 699 763 | 
             
                        end
         | 
| 700 764 |  | 
| @@ -0,0 +1,217 @@ | |
| 1 | 
            +
            module ThemeJuice
         | 
| 2 | 
            +
                module UI
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                    QUESTION_MARK = "?"
         | 
| 5 | 
            +
                    BULLET_HOLLOW = "\u25CB"
         | 
| 6 | 
            +
                    BULLET_SOLID  = "\u2022"
         | 
| 7 | 
            +
                    ARROW_UP      = "\u2191"
         | 
| 8 | 
            +
                    ARROW_RIGHT   = "\u2192"
         | 
| 9 | 
            +
                    ARROW_DOWN    = "\u2193"
         | 
| 10 | 
            +
                    ARROW_LEFT    = "\u2190"
         | 
| 11 | 
            +
                    ARROW_RELOAD  = "\u21AA"
         | 
| 12 | 
            +
                    BLOCK_LARGE   = "\u2588"
         | 
| 13 | 
            +
                    BLOCK_MED     = "\u258D"
         | 
| 14 | 
            +
                    BLOCK_SMALL   = "\u258F"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    class << self
         | 
| 17 | 
            +
                        include ::Thor::Actions
         | 
| 18 | 
            +
                        include ::Thor::Shell
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                        ###
         | 
| 21 | 
            +
                        # Output formatted message to terminal
         | 
| 22 | 
            +
                        #
         | 
| 23 | 
            +
                        # @param {String} message
         | 
| 24 | 
            +
                        # @param {Hash}   opts
         | 
| 25 | 
            +
                        #
         | 
| 26 | 
            +
                        # @return {Void}
         | 
| 27 | 
            +
                        ###
         | 
| 28 | 
            +
                        def speak(message, opts = {})
         | 
| 29 | 
            +
                            format_message! message, opts
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                            # Check if we're suppressing terminal output
         | 
| 32 | 
            +
                            if opts.key? :suppress
         | 
| 33 | 
            +
                                message
         | 
| 34 | 
            +
                            else
         | 
| 35 | 
            +
                                say message
         | 
| 36 | 
            +
                            end
         | 
| 37 | 
            +
                        end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                        ###
         | 
| 40 | 
            +
                        # Output success message
         | 
| 41 | 
            +
                        #
         | 
| 42 | 
            +
                        # @param {String} message
         | 
| 43 | 
            +
                        #
         | 
| 44 | 
            +
                        # @return {Void}
         | 
| 45 | 
            +
                        ###
         | 
| 46 | 
            +
                        def success(message)
         | 
| 47 | 
            +
                            self.speak message, {
         | 
| 48 | 
            +
                                color: [:black, :on_green, :bold],
         | 
| 49 | 
            +
                                full_width: true
         | 
| 50 | 
            +
                            }
         | 
| 51 | 
            +
                        end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                        ###
         | 
| 54 | 
            +
                        # Output notice message
         | 
| 55 | 
            +
                        #
         | 
| 56 | 
            +
                        # @param {String} message
         | 
| 57 | 
            +
                        #
         | 
| 58 | 
            +
                        # @return {Void}
         | 
| 59 | 
            +
                        ###
         | 
| 60 | 
            +
                        def notice(message)
         | 
| 61 | 
            +
                            self.speak message, {
         | 
| 62 | 
            +
                                color: [:black, :on_yellow],
         | 
| 63 | 
            +
                                icon: :arrow_right,
         | 
| 64 | 
            +
                                full_width: true
         | 
| 65 | 
            +
                            }
         | 
| 66 | 
            +
                        end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                        ###
         | 
| 69 | 
            +
                        # Output error message and exit. Allows a block to be passed
         | 
| 70 | 
            +
                        #  as well, which will be executed before exiting
         | 
| 71 | 
            +
                        #
         | 
| 72 | 
            +
                        # @param {String} message
         | 
| 73 | 
            +
                        #
         | 
| 74 | 
            +
                        # @return {Void}
         | 
| 75 | 
            +
                        ###
         | 
| 76 | 
            +
                        def error(message)
         | 
| 77 | 
            +
                            self.speak message, {
         | 
| 78 | 
            +
                                color: [:white, :on_red],
         | 
| 79 | 
            +
                                icon: :arrow_up,
         | 
| 80 | 
            +
                                full_width: true
         | 
| 81 | 
            +
                            }
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                            yield if block_given?
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                            exit 1
         | 
| 86 | 
            +
                        end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                        ###
         | 
| 89 | 
            +
                        # Output a list of messages
         | 
| 90 | 
            +
                        #
         | 
| 91 | 
            +
                        # @param {String} header
         | 
| 92 | 
            +
                        # @param {Symbol} color
         | 
| 93 | 
            +
                        # @param {Array}  list
         | 
| 94 | 
            +
                        #
         | 
| 95 | 
            +
                        # @return {Void}
         | 
| 96 | 
            +
                        ###
         | 
| 97 | 
            +
                        def list(header, color, list)
         | 
| 98 | 
            +
                            self.speak header, {
         | 
| 99 | 
            +
                                color: [:black, :"on_#{color}"],
         | 
| 100 | 
            +
                                icon: :arrow_right,
         | 
| 101 | 
            +
                                full_width: true
         | 
| 102 | 
            +
                            }
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                            list.each do |item|
         | 
| 105 | 
            +
                                self.speak item, {
         | 
| 106 | 
            +
                                    color: :"#{color}",
         | 
| 107 | 
            +
                                    icon: :bullet_solid
         | 
| 108 | 
            +
                                }
         | 
| 109 | 
            +
                            end
         | 
| 110 | 
            +
                        end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                        ###
         | 
| 113 | 
            +
                        # Ask a question
         | 
| 114 | 
            +
                        #
         | 
| 115 | 
            +
                        # @param {String} question
         | 
| 116 | 
            +
                        # @param {Hash}   opts
         | 
| 117 | 
            +
                        #
         | 
| 118 | 
            +
                        # @return {Void}
         | 
| 119 | 
            +
                        ###
         | 
| 120 | 
            +
                        def prompt(question, *opts)
         | 
| 121 | 
            +
                            format_message! question, {
         | 
| 122 | 
            +
                                color: :blue,
         | 
| 123 | 
            +
                                icon: :bullet_hollow
         | 
| 124 | 
            +
                            }
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                            opts.each do |opt|
         | 
| 127 | 
            +
                                if opt.respond_to? :key?
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                                    # if opt.key? :default
         | 
| 130 | 
            +
                                    #     opt[:default] = set_color(opt[:default], :black, :bold)
         | 
| 131 | 
            +
                                    # end
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                                    if opt.key? :indent
         | 
| 134 | 
            +
                                        set!(question) { |str| (" " * opt[:indent]) << str }
         | 
| 135 | 
            +
                                    end
         | 
| 136 | 
            +
                                end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                                break
         | 
| 139 | 
            +
                            end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                            ask "#{question} :", *opts
         | 
| 142 | 
            +
                        end
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                        ###
         | 
| 145 | 
            +
                        # Ask a yes or no question
         | 
| 146 | 
            +
                        #
         | 
| 147 | 
            +
                        # @param {String} question
         | 
| 148 | 
            +
                        # @param {Hash}   opts
         | 
| 149 | 
            +
                        #
         | 
| 150 | 
            +
                        # @return {Bool}
         | 
| 151 | 
            +
                        ###
         | 
| 152 | 
            +
                        def agree?(question, opts = {})
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                            unless opts.key? :color
         | 
| 155 | 
            +
                                opts[:color] = :blue
         | 
| 156 | 
            +
                            end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                            format_message! question, {
         | 
| 159 | 
            +
                                color: opts[:color],
         | 
| 160 | 
            +
                                icon: :bullet_hollow
         | 
| 161 | 
            +
                            }
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                            if opts.key? :simple
         | 
| 164 | 
            +
                                yes? " :", if opts.key? :color then opts[:color] end
         | 
| 165 | 
            +
                            else
         | 
| 166 | 
            +
                                yes? "#{question} (y/N) :"
         | 
| 167 | 
            +
                            end
         | 
| 168 | 
            +
                        end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                        private
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                        ###
         | 
| 173 | 
            +
                        # Destructively format message
         | 
| 174 | 
            +
                        #
         | 
| 175 | 
            +
                        # @param {String} message
         | 
| 176 | 
            +
                        # @param {Hash}   opts
         | 
| 177 | 
            +
                        #
         | 
| 178 | 
            +
                        # @return {String}
         | 
| 179 | 
            +
                        ###
         | 
| 180 | 
            +
                        def format_message!(message, opts = {})
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                            # Check if we're using an icon
         | 
| 183 | 
            +
                            unless ::ThemeJuice::Utilities.no_unicode
         | 
| 184 | 
            +
                                if opts.key? :icon
         | 
| 185 | 
            +
                                    set!(message) { |msg| " #{self.const_get(opts[:icon].to_s.upcase)} " << msg if opts[:icon].is_a? Symbol }
         | 
| 186 | 
            +
                                else
         | 
| 187 | 
            +
                                    set!(message) { |msg| " " << msg }
         | 
| 188 | 
            +
                                end
         | 
| 189 | 
            +
                            end
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                            # Check if message should take up entire width
         | 
| 192 | 
            +
                            #  of the terminal window
         | 
| 193 | 
            +
                            if opts.key? :full_width
         | 
| 194 | 
            +
                                set!(message) { |msg| msg.ljust(terminal_width) }
         | 
| 195 | 
            +
                            end
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                            # Check if we're using colors
         | 
| 198 | 
            +
                            unless ::ThemeJuice::Utilities.no_colors
         | 
| 199 | 
            +
                                if opts.key? :color
         | 
| 200 | 
            +
                                    set!(message) { |msg| set_color(msg, *opts[:color]) }
         | 
| 201 | 
            +
                                end
         | 
| 202 | 
            +
                            end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                            message
         | 
| 205 | 
            +
                        end
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                        ###
         | 
| 208 | 
            +
                        # Run destructive block against message
         | 
| 209 | 
            +
                        #
         | 
| 210 | 
            +
                        # @return {String}
         | 
| 211 | 
            +
                        ###
         | 
| 212 | 
            +
                        def set!(string)
         | 
| 213 | 
            +
                            str = yield(string); string.clear; string << str
         | 
| 214 | 
            +
                        end
         | 
| 215 | 
            +
                    end
         | 
| 216 | 
            +
                end
         | 
| 217 | 
            +
            end
         | 
| @@ -1,37 +1,13 @@ | |
| 1 1 | 
             
            module ThemeJuice
         | 
| 2 2 | 
             
                module Utilities
         | 
| 3 3 | 
             
                    class << self
         | 
| 4 | 
            +
                        attr_accessor :vvv_path
         | 
| 5 | 
            +
                        attr_accessor :no_unicode
         | 
| 6 | 
            +
                        attr_accessor :no_colors
         | 
| 7 | 
            +
             | 
| 4 8 | 
             
                        include ::Thor::Actions
         | 
| 5 9 | 
             
                        include ::Thor::Shell
         | 
| 6 10 |  | 
| 7 | 
            -
                        @@vvv_path ||= File.expand_path("~/vagrant")
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                        ###
         | 
| 10 | 
            -
                        # Set path to VVV installation
         | 
| 11 | 
            -
                        #
         | 
| 12 | 
            -
                        # @param {String} path
         | 
| 13 | 
            -
                        #
         | 
| 14 | 
            -
                        # @return {String}
         | 
| 15 | 
            -
                        ###
         | 
| 16 | 
            -
                        def set_vvv_path(path)
         | 
| 17 | 
            -
                            @@vvv_path = File.expand_path(path)
         | 
| 18 | 
            -
                        end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                        ###
         | 
| 21 | 
            -
                        # Get path to VVV installation
         | 
| 22 | 
            -
                        #
         | 
| 23 | 
            -
                        # @return {String}
         | 
| 24 | 
            -
                        ###
         | 
| 25 | 
            -
                        def get_vvv_path
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                            unless @@vvv_path
         | 
| 28 | 
            -
                                say " ↑ Cannot load VVV path. Aborting mission before something bad happens.".ljust(terminal_width), [:white, :on_red]
         | 
| 29 | 
            -
                                exit 1
         | 
| 30 | 
            -
                            end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                            @@vvv_path
         | 
| 33 | 
            -
                        end
         | 
| 34 | 
            -
             | 
| 35 11 | 
             
                        ###
         | 
| 36 12 | 
             
                        # Check if program is installed
         | 
| 37 13 | 
             
                        #
         | 
| @@ -60,9 +36,17 @@ module ThemeJuice | |
| 60 36 | 
             
                            remote_version = remotes.map { |n, _| n.version }.sort.last
         | 
| 61 37 |  | 
| 62 38 | 
             
                            if ::Gem::Version.new(local_version) < ::Gem::Version.new(remote_version)
         | 
| 63 | 
            -
                                 | 
| 39 | 
            +
                                ::ThemeJuice::UI.speak "Your version of Theme Juice (#{local_version}) is outdated. There is a newer version (#{remote_version}) available. Please update now.", {
         | 
| 40 | 
            +
                                    color: [:black, :on_yellow],
         | 
| 41 | 
            +
                                    icon: :arrow_right,
         | 
| 42 | 
            +
                                    full_width: true
         | 
| 43 | 
            +
                                }
         | 
| 64 44 | 
             
                            else
         | 
| 65 | 
            -
                                 | 
| 45 | 
            +
                                ::ThemeJuice::UI.speak "Your version of Theme Juice (#{local_version}) up to date.", {
         | 
| 46 | 
            +
                                    color: [:black, :on_green],
         | 
| 47 | 
            +
                                    icon: :arrow_right,
         | 
| 48 | 
            +
                                    full_width: true
         | 
| 49 | 
            +
                                }
         | 
| 66 50 | 
             
                            end
         | 
| 67 51 | 
             
                        end
         | 
| 68 52 | 
             
                    end
         | 
    
        data/lib/theme-juice/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: theme-juice
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ezekiel Gabrielse
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-02- | 
| 11 | 
            +
            date: 2015-02-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: thor
         | 
| @@ -49,6 +49,7 @@ extra_rdoc_files: [] | |
| 49 49 | 
             
            files:
         | 
| 50 50 | 
             
            - lib/theme-juice/cli.rb
         | 
| 51 51 | 
             
            - lib/theme-juice/executor.rb
         | 
| 52 | 
            +
            - lib/theme-juice/ui.rb
         | 
| 52 53 | 
             
            - lib/theme-juice/utilities.rb
         | 
| 53 54 | 
             
            - lib/theme-juice/version.rb
         | 
| 54 55 | 
             
            - lib/theme-juice.rb
         |